package juc.comfunc;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;

public class TestCompletableFuture {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
            System.out.println("无返回值");
        });

        CompletableFuture<String> future1 = CompletableFuture.supplyAsync(() -> {
            System.out.println("有返回值");
            return "bye";
        }, Executors.newSingleThreadExecutor());

        System.out.println(future1.get());
    }
}
